package com.ooho.messageboard.service;

import com.ooho.messageboard.dao.MessageDAO;
import com.ooho.messageboard.model.MessageBean;

import java.util.List;

/**
 * Created by hugohoo on 10/15/16.
 */
public class MessageService {

    public static List<MessageBean> find(){
        MessageDAO md = new MessageDAO();
        List<MessageBean> list = md.find();
        md.close();

        return list;
    }

    public static MessageBean find(int id){
        MessageDAO md = new MessageDAO();
        MessageBean mb = md.find(id);
        md.close();

        return mb;
    }

    public static MessageBean insert(MessageBean value){
        MessageDAO mdao = new MessageDAO();
        MessageBean mb = mdao.insert(value);
        mdao.close();

        return mb;
    }

    public static int update(MessageBean value){
        MessageDAO mdao = new MessageDAO();
        int rslt = mdao.update(value);

        mdao.close();

        return rslt;
    }

    public static int delete(MessageBean value){
        MessageDAO mdao = new MessageDAO();
        int rslt = mdao.delete(value);
        mdao.close();

        return rslt;
    }

}
